package com.sjsoft.chat.video;


import com.aphidmobile.flip.FlipViewController;
import com.sjsoft.app.video.R;
import com.sjsoft.application.chatVideoApp;
import com.sjsoft.model.SmsItem;
import com.sjsoft.payment.PayCard;
import com.sjsoft.payment.PaySms;
import com.sjsoft.video.LoadPrefixcode;
import com.sjsoft.video.loadPaymentInfor;
import com.sjsoft.webservice.UtilsJson;


import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.ImageView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;


public class PayMoney extends Activity {
	
	
	protected Context context;
	protected chatVideoApp application;
	private String sPrefixcode;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
		setContentView(R.layout.pay_money);//content_layout
		context = this;
		application = (chatVideoApp)getApplicationContext();
		if(application != null)
			sPrefixcode = application.sPrefixCode;
		else
			sPrefixcode = "";
		
		setupMobiCard();
		setupVinaCard();
		setupViettelCard();
		setupSms5();
		setupSms10();
		setupSms15();
		
	}
    
    public void setPrefixcode(String prefixcode)
    {
    	sPrefixcode = prefixcode;
    	application.sPrefixCode = prefixcode;
    }
    
    public void setupMobiCard()
    {
    	ImageView mobi_img = (ImageView)findViewById(R.id.img_mobi);
    	mobi_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityCard("VMS");
			}
		});
    }
    
    public void setupVinaCard()
    {
    	ImageView vina_img = (ImageView)findViewById(R.id.img_vina);
    	vina_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityCard("VNP");
			}
		});
    }
    
    public void setupViettelCard()
    {
    	ImageView vietel_img = (ImageView)findViewById(R.id.img_viettel);
    	vietel_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivityCard("VTE");
			}
		});
    }
       
    public void setupSms15()
    {
    	ImageView sms15_img = (ImageView)findViewById(R.id.img_sms15);
    	sms15_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub							
					startActivitySms(3);					
			}
		});
    }
    
    public void setupSms5()
    {
    	ImageView sms5_img = (ImageView)findViewById(R.id.img_sms5);
    	sms5_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub							
					startActivitySms(1);					
			}
		});
    }
    
    public void setupSms10()
    {
    	ImageView sms10_img = (ImageView)findViewById(R.id.img_sms10);
    	sms10_img.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub							
					startActivitySms(2);					
			}
		});
    }
    
    
    public void startActivityCard(String sCenter)
    {
    	Intent payIntent = new Intent().setClass(this, PayCard.class);
    	payIntent.putExtra("Network", sCenter);
		startActivity(payIntent);
    }
    
    public void startActivitySms(int nType)
    {
    	
    		Intent payIntent = new Intent().setClass(this, PaySms.class);
    		SmsItem item = null;
    		if(nType == 1)
    			item = application.getSms5();
    		if(nType == 2)
    			item = application.getSms10();
    		if(nType == 3)
    			item = application.getSms15();
    	if(item != null)
    	{    		
    		payIntent.putExtra("Number",item.sNumber);
    		
    		payIntent.putExtra("Content", item.sContent);
    		startActivity(payIntent);
		}
    	else
    	{
    		//pay money don't successfully
    	}
    }
    
}
